home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / label_alloc.pro < prev    next >
Encoding:
Text File  |  1997-07-08  |  6.2 KB  |  250 lines

  1. ;
  2. ; $Id: label_alloc.pro,v 1.11 1997/03/18 00:08:13 lubos Exp $
  3. ;
  4. ;  WidLabel
  5. ;   Widget Label class library
  6. ;
  7. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  8. ;   Unauthorized reproduction prohibited.
  9. ;
  10. ; MODIFICATION HISTORY
  11. ;       Written by:     Joshua Goldstein,       12/93
  12. ;
  13. ;
  14.  
  15.  
  16. ;
  17. ;  LABEL_Icon
  18. ;       Return the label toolbar icon
  19. ;
  20. FUNCTION LABEL_Icon
  21.   RETURN, [ $
  22.     [ 0b, 0b, 0b, 0b ], $
  23.     [ 0b, 0b, 0b, 0b ], $
  24.     [ 0b, 0b, 0b, 0b ], $
  25.     [ 0b, 0b, 0b, 0b ], $
  26.     [ 0b, 0b, 0b, 0b ], $
  27.     [ 0b, 0b, 0b, 0b ], $
  28.     [ 0b, 0b, 0b, 0b ], $
  29.     [ 0b, 0b, 0b, 0b ], $
  30.     [ 0b, 128b, 1b, 0b ], $
  31.     [ 0b, 128b, 1b, 0b ], $
  32.     [ 0b, 128b, 1b, 0b ], $
  33.     [ 0b, 64b, 3b, 0b ], $
  34.     [ 0b, 64b, 3b, 0b ], $
  35.     [ 0b, 64b, 3b, 0b ], $
  36.     [ 0b, 32b, 6b, 0b ], $
  37.     [ 0b, 32b, 6b, 0b ], $
  38.     [ 0b, 32b, 6b, 0b ], $
  39.     [ 0b, 16b, 12b, 0b ], $
  40.     [ 0b, 240b, 15b, 0b ], $
  41.     [ 0b, 16b, 12b, 0b ], $
  42.     [ 0b, 8b, 24b, 0b ], $
  43.     [ 0b, 8b, 24b, 0b ], $
  44.     [ 0b, 8b, 24b, 0b ], $
  45.     [ 0b, 28b, 60b, 0b ], $
  46.     [ 0b, 0b, 0b, 0b ], $
  47.     [ 0b, 0b, 0b, 0b ], $
  48.     [ 0b, 0b, 0b, 0b ], $
  49.     [ 0b, 0b, 0b, 0b ], $
  50.     [ 0b, 0b, 0b, 0b ], $
  51.     [ 0b, 0b, 0b, 0b ], $
  52.     [ 0b, 0b, 0b, 0b ], $
  53.     [ 0b, 0b, 0b, 0b ]  $
  54.   ]
  55. END
  56.  
  57.  
  58. ;
  59. ;  LABEL_Copy
  60. ;   Copy a label.  2 copy methods:
  61. ;
  62. ;   if( copy != NULL)       { *copy = *ptr; free(ptr); }
  63. ;   else                    { *(copy = malloc(...)) = *ptr; }
  64. ;
  65. PRO LABEL_Copy, Ptr, Copy
  66.     GenCopy, Ptr, Copy
  67. END
  68.  
  69.  
  70. ;
  71. ;  LABEL_Destroy
  72. ;   Release resources for the given label
  73. ;
  74. PRO LABEL_Destroy, Ptr
  75.     GenDestroy, Ptr
  76. END
  77.  
  78.  
  79. ;
  80. ;  LABEL_Event
  81. ;   Event handling routine for a label dialog.  Shares common code
  82. ;   (c.f. widbuild.pro)
  83. ;
  84. PRO LABEL_Event, Event
  85.     MISC_Event, Event, 1    ; constant is Font Offset in Foci
  86. END
  87.  
  88.  
  89.  
  90. ;
  91. ;  LABEL_Build
  92. ;   Create a dialog box a label object.  If ptr is nil then
  93. ;   create the object as well.
  94. ;
  95. PRO LABEL_Build, Ptr, ParPtr
  96.  
  97.   COMMON WidEd_Comm
  98.  
  99.     LABEL_Alloc, ParPtr, Ptr                ; Allocate object if necessary
  100.     MgrName = 'WE_LABEL' + STRTRIM(Ptr, 2)  ; Create dialog box name
  101.     IF XRegistered(MgrName) THEN RETURN     ; See if it already exists
  102.  
  103.     Title   = GetId(Ptr) + '(Child of ' + GetId(ParPtr) + ')'
  104.     Ptr2Obj, Ptr, Obj
  105.  
  106.     ;   Create dialog box
  107.  
  108.     IF SmallScreen[0] NE 0 THEN BEGIN
  109.         Base    = WIDGET_BASE(/COLUMN, TITLE=Title, GROUP_LEADER=TopDlg, $
  110.                         X_SCROLL_SIZE=SmallScreen[0], $
  111.                         Y_SCROLL_SIZE=SmallScreen[1] )
  112.     ENDIF ELSE BEGIN
  113.         Base    = WIDGET_BASE(/COLUMN, TITLE=Title, GROUP_LEADER=TopDlg)
  114.     ENDELSE
  115.     Foci    = LONARR(9)
  116.  
  117.     Base1   = WIDGET_BASE(Base, /FRAME, /COLUMN)
  118.     Lab     = WIDGET_LABEL(Base1, VALUE="Basic Information")
  119.     Foci[0] = Field(Base1, "Label Text:", Obj.Value, 'VALUE', SIZE=50, /STRING)
  120.     Base2   = WIDGET_BASE(Base1,/ROW)
  121.     Foci[1] = Field(Base2, "Font:", Obj.Font, 'FONT', SIZE=50, /STRING)
  122.     IF !Version.OS NE 'Win32' AND !Version.OS NE 'MacOS' THEN $
  123.         XFontBtn    = WIDGET_BUTTON(Base2, VALUE="XFont", UVALUE="XFONT")
  124.  
  125.  
  126.     BuildOther, Base, Obj, Foci, 2, /FRAME
  127.  
  128.     Base1   = WIDGET_BASE(Base, /FRAME, /COLUMN)
  129.     Lab     = WIDGET_LABEL(Base1, VALUE="Label Appearance Controls")
  130.     BuildXY, Base1, Obj, Foci, 5, /SIZE, /OFFSET
  131.     BuildOkCancel, Base, Obj
  132.  
  133.     DlgInfo     = { $
  134.         Foci:       Foci, $
  135.         ObjPtr:     Ptr $
  136.     }
  137.     Obj.Dialog  = Base
  138.     WIDGET_CONTROL, Base, SET_UVALUE=DlgInfo, /NO_COPY
  139.     WIDGET_CONTROL, Base, /REALIZE
  140.     XMANAGER, MgrName, Base, EVENT_HANDLER='LABEL_Event', CLEANUP='MISC_Kill'
  141.     Obj2Ptr, Obj, Ptr
  142. END
  143.  
  144.  
  145. ;
  146. ;  LABEL_Save
  147. ;   Save label information to a file.
  148. ;   This is a simple object to save.
  149. ;
  150. PRO LABEL_Save, Unit, Ptr
  151.     GenWrite, Unit, Ptr
  152. END
  153.  
  154.  
  155. ;
  156. ;  LABEL_Restore
  157. ;   Read in a label object from a file
  158. ;
  159. PRO LABEL_Restore, Unit, Parent, Ptr
  160.     MISC_Restore, Unit, Parent, Ptr, "LABEL", 0
  161. END
  162.  
  163.  
  164. ;
  165. ;  LABEL_Generate
  166. ;   Create a label object for previewing
  167. ;
  168. PRO LABEL_Generate, Base, Ptr
  169.   COMMON WidEd_Comm
  170.  
  171.     Ptr2Obj, Ptr, Obj
  172.     Id  = 0L            ; Prevent EXECUTE from creating a new variable
  173.  
  174.     ;   Build a command string
  175.  
  176.     Cmd = 'Id = WIDGET_LABEL(Base'
  177.     SAddCmd, Cmd, Obj.Font, 'FONT'
  178.     IAddCmd, Cmd, Obj.FrameSize, 'FRAME'
  179.     SAddCmd, Cmd, Obj.Value, 'VALUE'
  180.     IAddCmd, Cmd, Obj.XSize, 'XSIZE'
  181.     IAddCmd, Cmd, Obj.YSize, 'YSIZE'
  182.     IAddCmd, Cmd, Obj.XOffset, 'XOFFSET'
  183.     IAddCmd, Cmd, Obj.YOffset, 'YOFFSET'
  184.  
  185.     Obj2Ptr, Obj, Ptr
  186.  
  187.     ; Create label by executing the command string we just built
  188.  
  189.     IF EXECUTE(Cmd+')') NE 1 THEN BEGIN
  190.         MESSAGE,'Could not create Label ' + VarName[Ptr]
  191.     ENDIF
  192. END
  193.  
  194.  
  195. ;
  196. ;  LABEL_GenWid
  197. ;   Create IDL code for creating a LABEL
  198. ;
  199. PRO LABEL_GenWid, Unit, Ptr, Parent
  200.  
  201.     Name    = VarId(Ptr)            ; Get name for label
  202.     Ptr2Obj, Ptr, Obj               ; Get object information
  203.  
  204.     XPRINTF, Unit, FORMAT='("  ",A," = WIDGET_LABEL( ",A)', $
  205.         Name, Parent, /NO_EOL
  206.     SSaveCmd, Unit, Obj.Font, "FONT"
  207.     ISaveCmd, Unit, Obj.FrameSize, "FRAME"
  208.     SSaveCmd, Unit, UValue(Obj, Ptr), "UVALUE"
  209.     SSaveCmd, Unit, Obj.Value, "VALUE"
  210.     ISaveCmd, Unit, Obj.XOffset, "XOFFSET"
  211.     ISaveCmd, Unit, Obj.XSize, "XSIZE"
  212.     ISaveCmd, Unit, Obj.YOffset, "YOFFSET"
  213.     ISaveCmd, Unit, Obj.YSize, "YSIZE"
  214.     XPRINTF, Unit, ')'
  215.  
  216.     Obj2Ptr, Obj, Ptr
  217. END
  218.  
  219.  
  220. ;
  221. ;  LABEL_Alloc
  222. ;       Allocate a label object.  Don't allocate if ptr is non-nil
  223. ;
  224. PRO LABEL_Alloc, Parent, Ptr
  225.   COMMON WidEd_Comm
  226.  
  227.     IF KEYWORD_SET(Ptr) NE 0 THEN RETURN    ; if(ptr != NULL) return;
  228.  
  229.     Ptr = WIDGET_BASE(GROUP=TopDlg)         ; Make a pointer
  230.  
  231.     Obj = {                     $
  232.         WE_LABEL,               $
  233.         Type:           'LABEL',$
  234.         Parent:         Parent, $ ; Pointer to parent
  235.         Id:             NewId(),$ ; Permanent Id
  236.         Dialog:         0L,     $ ; Save Dialog ID (need for Cut consistency)
  237.         Next:           0L,     $ ; index of next child/free/top
  238.         Name:           '',     $ ; object name
  239.         FrameSize:      0,      $
  240.         Font:           '',     $
  241.         XSize:          0,      $
  242.         YSize:          0,      $
  243.         XOffset:        0,      $
  244.         YOffset:        0,      $
  245.         UValue:         '',     $
  246.         Value:          ''      $
  247.     }
  248.     Obj2Ptr, Obj, Ptr
  249. END
  250.